﻿using MenuItem = OMC.DataManagement.MenuItem;
using System.Collections.Generic;

namespace OMC.Classification
{
    /// <summary>
    /// an object of this class could manage all about the
    /// Prediction of the Result
    /// </summary>
    /// <remarks>
    /// Copyright 2012 Stefan Lütolf
    /// </remarks>
    public class Prediction
    {
        private double[] TheResultsArray;
        private TextClassifier TheTextClassifier;
        //boarderline of the predicted folders, (0.15 = 15%)
        private const double TheMinOfPercentOf = 0.15;

        /// <summary>
        /// constructor to create a Prediction object
        /// </summary>
        /// <param name="inTextClassifier">The TextClassifier</param>
        /// <param name="inResults">a double Array of Results</param>
        public Prediction(TextClassifier inTextClassifier, ref double[] inResults)
        {
            this.TheResultsArray = inResults;
            this.TheTextClassifier = inTextClassifier;
        }

        /// <summary>
        /// to make a prediction, which classes passes
        /// </summary>
        /// <param name="inList">a referenced list, to fill in the predicted class</param>
        public void getPredictedClassNameList(ref List<MenuItem> inList)
        {
            double temp = 0.0;
            int res = 0;
            for (int i = 0; i < TheResultsArray.Length; i++)
            {
                if (temp < TheResultsArray[i])
                {
                    temp = TheResultsArray[i];
                    res = i;
                    if (temp > TheMinOfPercentOf)
                    {
                        inList.Add(new MenuItem(TheTextClassifier.getCategory(res), (int)(temp * 100)));
                        //Utils.Debug.print("tempwert: " + (int)(temp * 100) + " % , classname: " + TheTextClassifier.getCategory(res));
                    }
                }
            }
        }
    }
}